<template>
 <div>
      <a class="btn btn-default navbar-btn sign-up" data-sign="signup" data-toggle="modal" @click="add_section">添加章节</a>
      <lab_header :title='"添加章节"'  />

        <div class="container layout layout-margin-top">
        
        
        <div class="row">
            <div class="col-md-9 layout-body">
                
        <div class="content">
            <!-- <div class="row"> -->
                
            <div role="tabpanel" class="tab-pane active" id="signin-form">
                        <form action="/login" method="post">
                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-envelope" style="margin:0;"></i>
                                    </div>
                                    <input type="text" class="form-control" v-model="user_id" placeholder="请输入用户id:user_id">
                                </div>
                            </div>
                            <br>
                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-lock" style="margin:0;"></i>
                                    </div>
                                    <input type="text" class="form-control" v-model="is_delete" placeholder="is_delete">
                                </div>
                            </div>
                            <br>
                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-lock" style="margin:0;"></i>
                                    </div>
                                    <input type="text" class="form-control" v-model="id" placeholder="id">
                                </div>
                            </div>
                            <br>
                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-lock" style="margin:0;"></i>
                                    </div>
                                    <input type="text" class="form-control" v-model="title" placeholder="title">
                                </div>
                            </div>
                            <br>
                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-lock" style="margin:0;"></i>
                                    </div>
                                    <input type="text" class="form-control" v-model="serial_num" placeholder="serial_num">
                                </div>
                            </div>
                            <br>
                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-lock" style="margin:0;"></i>
                                    </div>
                                    <input type="text" class="form-control" v-model="course_id" placeholder="cuorse_id">
                                </div>
                            </div>
                            <br>
                          <div class="form-group">
                                
                            <div v-width="300"><Button class="h-btn h-btn-text-green h-btn-block" @click="add_chapters">添加章节</Button></div>

                          </div>
                        </form>
                    </div>
                
      
            
            <!-- </div> -->
        </div>

            </div>
                <div class="col-md-3 layout-side">
                </div>
            </div>
        </div>
 </div>


</template>

<script>
import {add_chapters_post} from '../components/axios_api/api'
import comment from '../components/common/comment.vue';
export default {
  components: { comment },
    data(){
        return{
            title: '',
            user_id:'',
            is_delete:'',
            id:'',
            course_id:'',
            serial_num:'',
            token:'',
        };
    },methods:{
        add_chapters(){
            var data ={title:this.title,user_id:this.user_id,id:this.id,course_id:this.course_id,serial_num:this.serial_num,is_delete:this.is_delete}
            add_chapters_post(data).then(resp=>{
            this.token = localStorage.getItem("token")
            console.log('添加成功',resp)
            if(resp.code==200){
            alert('添加成功')
            this.$router.push('/')
            }
            }).catch(err=>{
                console.log(err)
                alert('添加失败')
                this.$router.push('/')
            })
        },add_section(){
            this.$router.push('/add_sections')
        }
    }
}
</script>

<style>

</style>